package com.zzxy.aspect;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspectJ {

    @Before(value = "execution(* com.zzxy.service.impl.*.*(..))")
    public void myBefore(JoinPoint joinpoint){
        System.out.println("before methoda:"+joinpoint.getSignature().getName());
        System.out.println("my before .... ");
    }
    public void myAfter(JoinPoint joinpoint){
        System.out.println("after method:"+joinpoint.getSignature().getName());
        System.out.println("my after ...");
    }
    public Object myAround(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("before around :"+pjp.getSignature().getName());
        Object obj = pjp.proceed();
        System.out.println("after around : "+pjp.getSignature().getName());
        return obj;
    }
    public void myAfterReturning(JoinPoint joinPoint,Object ret){
        System.out.println("after returning method:" + joinPoint.getSignature().getName() + "return:" + ret);
    }
    public void myThrowing(JoinPoint joinPoint,Throwable e){

        System.out.println("my Throwing"+ e.getMessage());
    }
}
